﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace FreeSqlDemo.Services
{
    public class XlsxFileResult : XlsxFileResultBase
    {
        public XlsxFileResult(Stream stream, string fileDownloadName = null)
        {
            Stream = stream;
            FileDownloadName = fileDownloadName;
        }
        public XlsxFileResult(byte[] bytes, string fileDownloadName = null)
        {
            Stream = new MemoryStream(bytes);
            FileDownloadName = fileDownloadName;
        }

        public Stream Stream { get; protected set; }
        public string FileDownloadName { get; protected set; }


        public async override Task ExecuteResultAsync(ActionContext context)
        {
            await DownloadExcelFileAsync(context, Stream, FileDownloadName);
        }
    }
}
